<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改排课规则主')" />
    <th:block th:include="include :: datetimepicker-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-courseConfig-edit" th:object="${courseMainConfig}">
            <input name="id" th:field="*{id}" type="hidden">
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label is-required">年度：</label>
                    <div class="col-sm-8">
                        <input name="year" th:field="*{year}" class="form-control" type="number" max="9999" min="2000" required>
                    </div>
                </div>
            </div>
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label is-required">学期：</label>
                    <div class="col-sm-8">
                        <select class='form-control selectpicker' name="semesterId" id="semesterId" th:with="type=${@dict.getType('sc_term_type')}" th:field="*{semesterId}" required>
                            <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:selected="${dict.dictValue eq semesterId}"></option>
                        </select>
                    </div>
                </div>
            </div>
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label is-required">年级：</label>
                    <div class="col-sm-8">
                        <select class='form-control selectpicker' data-live-search="true" id='gradeId' name='gradeId'  th:with="type=${@grade.getGradeList()}" th:field="*{gradeId}" required>
                            <option th:selected="${gradeId eq c.id}" th:each="c:${type}" th:value="${c.id}" th:text="${c.gradeName}"></option>
                        </select>
                    </div>
                </div>
            </div>
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label is-required">描述：</label>
                    <div class="col-sm-8">
                        <input name="name" th:field="*{name}" class="form-control" type="text" required>
                    </div>
                </div>
            </div>
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label is-required">课次/天：</label>
                    <div class="col-sm-8">
                        <input name="sections" th:field="*{sections}" class="form-control" type="number" max="12" required>
                    </div>
                </div>
            </div>
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label is-required">周数：</label>
                    <div class="col-sm-8">
                        <input name="weeks" th:field="*{weeks}" class="form-control" type="number" min="1" max="4" required>
                    </div>
                </div>
            </div>
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label is-required">开始日期：</label>
                    <div class="col-sm-8">
                        <div class="input-group date">
                            <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                            <input name="bgDate" th:value="${#dates.format(courseMainConfig.bgDate, 'yyyy-MM-dd')}" class="form-control" placeholder="yyyy-MM-dd" type="text" required>
                        </div>
                    </div>
                </div>
            </div>
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label is-required">结束日期：</label>
                    <div class="col-sm-8">
                        <div class="input-group date">
                            <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                            <input name="edDate" th:value="${#dates.format(courseMainConfig.edDate, 'yyyy-MM-dd')}" class="form-control" placeholder="yyyy-MM-dd" type="text" required>
                        </div>
                    </div>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <script type="text/javascript">
        var prefix = ctx + "school/courseConfig";
        $("#form-courseConfig-edit").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/edit", $('#form-courseConfig-edit').serialize());
            }
        }

        $("input[name='bgDate']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            type: 'date',
            autoclose: true
        });
        $("input[name='edDate']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            type: 'date',
            autoclose: true
        });
    </script>
</body>
</html>